package utils

// Deprecated
import (
	"mall/common/globalkey"
	"mall/service/backend/common/enum/common"
)

type Option struct {
	CanAccept  bool
	CanReject  bool
	CanRemove  bool
	CanRestore bool
}

func GetOptionByStatus(status *uint32) *Option {
	res := &Option{}

	if status != nil {
		switch int32(*status) {
		case globalkey.StatusDisabled:
			res.CanAccept = true
			res.CanRemove = true
		case globalkey.StatusEnabled:
			res.CanReject = true
			res.CanRemove = true
		case globalkey.StatusDeleted:
			res.CanRestore = true
		}
	}

	return res
}

func GetOptionByStatusAndRoleIds(status *uint32, roleIds []uint64) *Option {
	res := &Option{}

	for _, id := range roleIds {
		if id <= common.DefaultAdminRoleId { // 是默认的系统管理员或超级管理员角色
			return res
		}
	}

	if status != nil {
		switch int32(*status) {
		case globalkey.StatusDisabled:
			res.CanAccept = true
			res.CanRemove = true
		case globalkey.StatusEnabled:
			res.CanReject = true
			res.CanRemove = true
		}
	}

	return res
}

func GetAuditOptionByStatus(status *uint32) *Option {
	res := &Option{}

	if status != nil {
		switch int32(*status) {
		case globalkey.StatusPending:
			res.CanAccept = true
			res.CanReject = true
			res.CanRemove = true
		case globalkey.StatusRejected:
			res.CanRemove = true
		case globalkey.StatusDeleted:
			res.CanRestore = true
		}
	}

	return res
}
